<?php //デフォルトのヘルパー読み込み?>
<?php use_helper("Validation")?>

<?php //カスタムでのヘルパー読み込み?>
<?php use_helper("MyPagerQuery")?>

<div id="contentLeft">

<?php echo form_tag("@bbssubmit","method=post multipart=true")?>
<!-- <form action="/bbssubmit/" method="post" enctype="multipart/form-data"> -->

内容
<?php echo textarea_tag("content", $content, array("rows" => 10, "cols" => 50))?>
<!-- <textarea name="content" cols="50" rows="10"></textarea> -->
<br>
<?php echo form_error("content")?>
<br>

<div id="contentBoxHr"></div>

<br>
名前
<?php echo input_tag("nickname", $nickname, array("size" => 20))?>
<!-- <input type="text" name="nickname" size="20"><br> -->
<br>
<?php echo form_error("nickname")?>
<br>

カテゴリ
<?php echo select_tag("category_id", options_for_select($categorys))?>
<!--
<select name="category_id">
<?php //foreach($categorys as $k => $v):?>
<option value="<?php //echo $k?>"><?php //echo $v?></option>
<?php //endforeach;?>
</select>
 -->

　　　URL
<?php echo input_tag("url", "@", array("size" => 40))?>
<br>
<!-- <input type="text" name="url" size="40"><br> -->
<br>

画像
<?php echo input_file_tag("photo")?>　　　

<?php echo input_hidden_tag("bbs_submit_check",$bbs_submit_check)?>
<?php echo submit_tag("投稿する")?>
<!-- <input type="submit"value="投稿する"> -->
</form>

<br>
<div id="contentBoxHr"></div>
<br>

<!-- 検索フォーム -->
<?php include_partial("default/kensaku", array("categorys"=>$categorys, "search_arr"=>$search_arr));?>
<!-- 検索フォームここまで -->
</div>

<div id="contentRight">
<?php include_component("default", "replyRanking");?>
</div>

<div class="clr"></div>
<hr>

<?php $query = parameter_to_query($sf_context->getModuleName(),
                                  $sf_context->getActionName(),
                                  $search_arr)?>

<?php include_partial("global/pager",
                       array( "pager" => $pager,
                              "query"=> $query)
      )
      /*上記の記述は、以下の記述がもと→$sf_context->getModuleName()."/".$sf_context->getActionName()."?"))*/?>


      <?php //昇順降順機能?>
<a href="/<?php echo $query?>">created_atを<?php echo $search_arr["order_by"]?>で並び替え</a>


<div class="commentBox">
<?php foreach($comments as $comment):?>
<?php echo $comment->getCreatedAt()?>
｜カテゴリ：<?php echo ($comment->getCategoryId())?$categorys[$comment->getCategoryID()]:"なし";?>
<br>

<?php if($comment->getUrl()):?>
<a href="<?php echo $comment->getUrl()?>">
<?php echo $comment->getNickname()?>
</a>
<?php else:?>
<?php echo $comment->getNickname()?>
<?php endif;?>
さんの投稿<br>
<?php echo $comment->getAccessCnt()?>

<?php echo nl2br($comment->getContent())?>
<br>

<?php if($comment->getPhoto() != ""):?>
<?php echo image_tag("comment/".$comment->getPhoto(), array("width" => 300))?>
<?php endif;?>
<br>
<a href="/comment/detail/id/<?php echo $comment->getId()?>">詳細</a>
<a href="/reply/index/id/<?php echo $comment->getId()?>">返信する</a>
</div>



<?php //foreach($comment->getReplys() as $reply):?>
<!-- getReplysFromCommentId()関数を作成し、同じ動作をさせる -->
<?php foreach($comment->getReplysFromCommentId() as $reply):?>
<div class="replyBox">
<?php echo $comment->getCreatedAt()?><br>
<?php echo $reply->getNickname()?>さんの返信<br>
<?php echo $reply->getContent()?><br>
<br>
</div>
<?php endforeach;?>


<?php endforeach;?>